package chapter11;

/**
 * Created by V5470-I5 on 2016/4/11.
 */
public class Hare implements Runnable {
    private boolean[] flags={true,false};
    private int totalStep;
    private int step;

    public Hare(int totalStep){
        this.totalStep=totalStep;
    }
    @Override
    public void run(){
        while(step<totalStep){
            boolean isHareSleep=flags[((int) (Math.random()*10))%2];
            if(isHareSleep){
                System.out.println("兔子睡着了zzz");
            }else{
                step+=2;
                System.out.printf("兔子跑了%d步...%n",step);
            }
        }
    }
}
